home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / sendmail.8.8.4.tar.gz / sendmail.8.8.4.tar / sendmail-8.8.4 / contrib / rmail.oldsys.patch < prev   
Internet Message Format  |  1994-06-19  |  3KB

  1. From: Bill Gianopoulos <wag@sccux1.msd.ray.com>
  2. Message-Id: <199405191527.LAA03463@sccux1.msd.ray.com>
  3. Subject: Patch to rmail to elliminate need for snprintf
  4. To: sendmail@CS.Berkeley.EDU
  5. Date: Thu, 19 May 1994 11:27:16 -0400 (EDT)
  6.  
  7. I have written the following patch to rmail which removes the requirement
  8. for snprintf while maintaining the protection from buffer overruns.  It also
  9. fixes it to compile with compilers which don't understand ANSI function
  10. prototypes.  Perhaps this should be included in the next version?
  11.  
  12. *** rmail/rmail.c.orig    Mon May 31 18:10:44 1993
  13. --- rmail/rmail.c    Thu May 19 11:04:50 1994
  14. ***************
  15. *** 78,86 ****
  16. --- 78,109 ----
  17.   #include <sysexits.h>
  18.   #include <unistd.h>
  19.   
  20. + #ifdef __STDC__
  21.   void err __P((int, const char *, ...));
  22.   void usage __P((void));
  23. + #else
  24. + void err ();
  25. + void usage ();
  26. + #endif
  27.   
  28. + #define strdup(s)    strcpy(xalloc(strlen(s) + 1), s)
  29. + char *
  30. + xalloc(sz)
  31. +     register int sz;
  32. + {
  33. +     register char *p;
  34. +     /* some systems can't handle size zero mallocs */
  35. +     if (sz <= 0)
  36. +         sz = 1;
  37. +     p = malloc((unsigned) sz);
  38. +     if (p == NULL)
  39. +         err(EX_UNAVAILABLE, "Out of memory!!");
  40. +     return (p);
  41. + }
  42.   int
  43.   main(argc, argv)
  44.       int argc;
  45. ***************
  46. *** 230,250 ****
  47.       args[i++] = "-oi";        /* Ignore '.' on a line by itself. */
  48.   
  49.       if (from_sys != NULL) {        /* Set sender's host name. */
  50. !         if (strchr(from_sys, '.') == NULL)
  51. !             (void)snprintf(buf, sizeof(buf),
  52.                   "-oMs%s.%s", from_sys, domain);
  53. !         else
  54. !             (void)snprintf(buf, sizeof(buf), "-oMs%s", from_sys);
  55.           if ((args[i++] = strdup(buf)) == NULL)
  56.                err(EX_TEMPFAIL, NULL);
  57.       }
  58.                       /* Set protocol used. */
  59. !     (void)snprintf(buf, sizeof(buf), "-oMr%s", domain);
  60.       if ((args[i++] = strdup(buf)) == NULL)
  61.           err(EX_TEMPFAIL, NULL);
  62.   
  63.                       /* Set name of ``from'' person. */
  64. !     (void)snprintf(buf, sizeof(buf), "-f%s%s",
  65.           from_path ? from_path : "", from_user);
  66.       if ((args[i++] = strdup(buf)) == NULL)
  67.           err(EX_TEMPFAIL, NULL);
  68. --- 253,285 ----
  69.       args[i++] = "-oi";        /* Ignore '.' on a line by itself. */
  70.   
  71.       if (from_sys != NULL) {        /* Set sender's host name. */
  72. !         if (strchr(from_sys, '.') == NULL) {
  73. !             if ((strlen(from_sys) + strlen(domain) + 6)
  74. !                 > sizeof(buf))
  75. !                 err(EX_DATAERR, "sender hostname too long");
  76. !             (void)sprintf(buf,
  77.                   "-oMs%s.%s", from_sys, domain);
  78. !         }
  79. !         else {
  80. !             if ((strlen(from_sys) + 5) > sizeof(buf))
  81. !                 err(EX_DATAERR ,"sender hostname too long");
  82. !             (void)sprintf(buf, "-oMs%s", from_sys);
  83. !         }
  84.           if ((args[i++] = strdup(buf)) == NULL)
  85.                err(EX_TEMPFAIL, NULL);
  86.       }
  87.                       /* Set protocol used. */
  88. !     if ((strlen(domain) + 5) > sizeof(buf))
  89. !         err(EX_DATAERR, "protocol name too long");
  90. !     (void)sprintf(buf, "-oMr%s", domain);
  91.       if ((args[i++] = strdup(buf)) == NULL)
  92.           err(EX_TEMPFAIL, NULL);
  93.   
  94.                       /* Set name of ``from'' person. */
  95. !     if (((from_path ? strlen(from_path) : 0) + strlen(from_user) + 3) 
  96. !         > sizeof(buf))
  97. !         err(EX_DATAERR, "from address too long");
  98. !     (void)sprintf(buf, "-f%s%s",
  99.           from_path ? from_path : "", from_user);
  100.       if ((args[i++] = strdup(buf)) == NULL)
  101.           err(EX_TEMPFAIL, NULL);
  102. -- 
  103. William A. Gianopoulos; Raytheon Missile Systems Division
  104. wag@sccux1.msd.ray.com
  105.